package com.liu.cloud.payment.controller;

import com.liu.cloud.common.entitys.Payment;
import com.liu.cloud.common.entitys.Result;
import com.liu.cloud.payment.service.impl.PaymentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
public class PaymentController {

    @Value("${server.port}")
    private String port;

      @Autowired
      private PaymentServiceImpl paymentService;

      @PostMapping("/pay/create")
      public Result<Payment> create( @RequestBody Payment payment){
          System.out.printf("**************"+payment.toString());
           int  result =paymentService.create(payment);
          return Result.getSuccess("插入成功",payment);
      }


      @GetMapping("/pay/{id}")
    public Result<Payment> findPaymentById(@PathVariable("id") long id){
          System.out.printf("*********id:"+id);
        Payment payment =paymentService.findbyId(id);

        return Result.getSuccess("查询成功"+port,payment);
    }
}
